package com.laysonx.demo.controller;

import com.laysonx.data.police.annotation.EnableDataVerify;
import com.laysonx.demo.api.ExampleApiService;
import com.laysonx.demo.entity.Demo;
import com.laysonx.demo.entity.Example;
import com.laysonx.demo.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: Laysonx
 * @date: 2019/9/27 21:18
 */
@RestController
public class DemoController {

    @Autowired
    private DemoService demoService;
    @Autowired
    private ExampleApiService exampleApiService;

    /**
     * @param
     * @description 测试接口 @EnableDataVerify 声明入口、校验对象
     * @author: Laysonx
     * @date: 2019/9/29 10:29
     * @return: com.laysonx.demo.entity.Demo
     */
    @GetMapping("demo")
    @EnableDataVerify(value = {Demo.class,Example.class}, errorMessage = "无权查看",tag = "EXCEPTION")
    public Demo getById() {
        Example example = exampleApiService.getById();
        return demoService.getById();
    }

    /**
     * 正常查询检测
     * @author: laysonx
     * @date: 2019/11/5 10:37
     * @param
     * @return: com.laysonx.demo.entity.Demo
     */
    @GetMapping("normal")
    @EnableDataVerify(value = {Demo.class})
    public Demo normalGet() {
        return demoService.getById();
    }
}
